package p10;

/**
 * @author krystal
 * @date 2022/11/12 20:25
 */
public class Demo2 {
    public static void main(String[] args) {
        String s1=new String("hello");
        String s2=new String("hello");
        String s3=new String("Hello");
        String s4=new String("world");

        System.out.println(s1 == s2);
        System.out.println(s2 == s3);

        //大小写敏感
        System.out.println("=================");
        System.out.println(s1.equals(s2));
        System.out.println(s1.equals(s3));
        System.out.println(s1.equals(s4));

        //大小写不敏感
        System.out.println("=================");
        System.out.println(s1.equalsIgnoreCase(s2));
        System.out.println(s1.equalsIgnoreCase(s3));
        System.out.println(s1.equalsIgnoreCase(s4));

        //比较两个字符串的大小关系
        System.out.println("=================");
        System.out.println(s1.compareTo(s2));
        System.out.println(s1.compareTo(s3));
    }
}
